 
create view vwGetOrderQty
as
SELECT BillNo,ERPCopGNo,ERPQty as OrderQty,
(select isnull(SUM (ERPQty),0) from PurReceivingDetails  as a left  join PurReceiving as b on a.HeadGUID =b.HeadGUID 
where b.POBillNo = c.BillNo  and a. CopGNo=c.ERPCopGNo)as SumQty
 FROM PurOrderDetails as c


